/**
 * 
 */
package kr.pe.smallhope.mobismap.widgets;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;

/**
 * @author silent
 * 
 */
public class GMapAddressCoordinateTableViewer extends TableViewer {

    /**
     * @param parent
     * @param style
     */
    public GMapAddressCoordinateTableViewer(Composite parent, int style) {
        super(parent, style);
        init();
    }

    /**
     * 
     */
    private void init() {
        String[] titles = { "Id", "QueryAddress", "Address", "Latitude",
                "Longitude", "CountryNameCode", "CountryName",
                "AdministrativeAreaName", "SubAdministrativeAreaName", "LocalityName",
                "DependentLocalityName", "ThoroughfareName", "AddressLine", "PostalCodeNumber" };
        int[] bounds = { 50, 190, 200, 90, 90, 80, 80, 80, 80, 80, 80, 80, 80, 80 };

        for (int i = 0; i < titles.length; i++) {
            int style = SWT.LEFT;
            if (i == 3 || i == 4) {
                style = SWT.RIGHT;
            }
            TableViewerColumn column = new TableViewerColumn(this, style);
            column.getColumn().setText(titles[i]);
            column.getColumn().setWidth(bounds[i]);
            column.getColumn().setResizable(true);
            column.getColumn().setMoveable(true);
        }
        Table table = getTable();
        table.setHeaderVisible(true);
        table.setLinesVisible(true);

        setContentProvider(new GMapAddressCoordinateTableContentProvider());
        setLabelProvider(new GMapAddressCoordinateTableLabelProvider());
    }

}
